<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
	
$Password = "";
$email = "";

if(isset($_REQUEST['Submit']) && ($_REQUEST['Submit'])=="Send Mail")
{
	
	
	$varEmail = mysql_real_escape_string($_REQUEST['mail_address']);
	$sql = "SELECT * FROM tblcustomers WHERE varcustemail = '$varEmail'";
	//echo $sql;
	$result = $n02586916_db->select($sql);
	if(count($result)>0)
	{
		//$Password = $result[0]['varcustpassword'];
		$Password = generatePassword();
		$mdpass=md5($Password);
		$email = $result[0]['varcustemail'];
		$to=$email;
		//echo $to;
		//die();
		$sqlemail = "select * from tblemails";
		$resemail = $n02586916_db->select($sqlemail);
		if($resemail)
		{
			$subject=stripslashes($resemail[0]['varpasssub']);
			$message12=stripslashes($resemail[0]['txtpassmess']);
		}
		$sqlsett = "select * from tblmystore";
		$resset = $n02586916_db->select($sqlsett);
		if($resset){$frm=$resset[0]['varfromemail']; $store=$resset[0]['varstorename'];}
		$from=$frm;
		
		$headers="From:".$store;
		$message=$message12."<br>"."Your Password is: ".$Password;
		$mailsubject=$subject;
		mail($to, $mailsubject, $message, $headers);
		
		$sql1="update tblcustomers set  varcustpassword = '$mdpass' WHERE varcustemail ='$varEmail'";
		$update_pass=mysql_query($sql1);
		header("location:thankyoumessage.php?msg=forgotpass");
	} else {
		$errmsg = $mess['emailnotfound'];
	}
}



?>
<?php include("inc/head.inc.php");?>
<body>
<table width="824" border="0" cellpadding="0" cellspacing="0"  align="center">
  <tr>
    <td class="headerclass"><?php include(INC."top.inc.php") ?></td>
  </tr>
  <tr>
    <td valign="top" class="maincontainer">
	
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr><td valign="top"class="leftmenuback"><?php include(INC."left.inc.php") ?></td>
        <td valign="top">
            <div class="pageheader">Lost Password?</div>
			<div class="msg">
					<?php 
					  if(isset($errmsg)) {
						echo $errmsg;
					  }
					?>
				  </div>
				  <br />
		  <form method="post" name="form1" action="forgotpassword.php" enctype="multipart/form-data">
		  <table width="50%" align="center"cellspacing="2" class="border">
            <tr>
              <td height="23" colspan="5" align="center" class="search">
                Please Enter Your Email              </td>
            </tr>
            <tr>
              <td width="7%">&nbsp;</td>
              <td width="18%" class="font">E-Mail</td>
              <td width="4%" class="font">:</td>
              <td width="64%"><label>
                <input name="mail_address" type="text" class="feature_headingbg" id="mail_address" size="30">
              </label></td>
              <td width="7%">&nbsp;</td>
            </tr>
            <tr>
              	<td colspan="5" align="center">                 
                  <input name="Submit" type="submit" class="btn" value="Send Mail" onClick="return check();" />
				</td>
            </tr>
          </table> 
		  </form>
	</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
</body>
</html>
